<?php
namespace app\wxapp\controller;

use app\wxapp\controller;
// use wxapp\aes\WXBizDataCrypt;
use think\Validate;
use think\Db;


class Rank extends Base
{   

    public function getGameRank()
    {   
        $game = input('game');
        $user_list = Db::name('game_rank')
                     ->alias('g')
                     ->join('user u','g.user_id = u.id','LEFT')
                     ->where('game',$game)
                     ->where('rank','<',21)
                     ->order('rank asc')
                     ->field('g.play_times,g.success_times,g.rank,u.nickName,u.avatarUrl')
                     ->select();
        
        $this->success("获取成功!", ['list' => $user_list]);
    }
    public function addUserInfo(){
        
        $data = $this->request->param();
        
        $user_info = json_decode($data['user_info'],true);
        $result    = Db::name('user')->where('id',$this->userId)->update($user_info);
        if($result || $result == 0){
            $this->success("添加成功!");
        }else{
            $this->success("添加失败!");
        }
    }

   

}